<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>生成模型</title>
    {include file="index/meta"/}
    <script>

    </script>

</head>
<body class="hold-transition sidebar-mini fixed">
<div class="wrapper-content">
    <section class="content-header">

    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-2" id="explain">

                <div class="box box-solid p-xs prettyAddonMenu">


                    <div class="box-header with-border">
                        <h3 class="pretty-box-title">核心设置</h3>
                    </div>
                    <div class="box-body no-padding">
                        <ul class="nav nav-pills nav-stacked">
                            <li class="active">
                                <a href="<?=url('gii/index/model')?>"
                                   title="模型生成器">
                                    模型生成器
                                </a>
                            </li>
                            <li>
                                <a href="<?=url('gii/index/curd')?>"
                                   title="CURD生成器">
                                    CURD生成器
                                </a>
                            </li>

                        </ul>
                        <div class="hr-line-dashed"></div>
                    </div>
                </div>
            </div>
            <div class="col-md-10">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="box">
                            <div class="box-header with-border">
                                <h3 class="box-title">生成模型</h3>
                                <div class="intro" style="margin:10px 0;color:green;font-size:15px;">
                                    <p>这一步会生成一个模型文件与数据表配置文件，生成完成后进入gii/table_configs目录找到相应模型数据表的配置文件，根据需求修改字段，然后进入下一步生成CURD操作</p>
                                </div>
                            </div>

                            <form id="pt_form" method="post">

                                <div class="box-body">

                                    <div class="form-group field-article-title required">
                                        <div class='col-sm-2 text-right'>
                                            <label class="control-label Validform_label"
                                                   for="tableName">完整表名</label>
                                        </div>
                                        <div class='col-sm-10'>
                                            <input type="text" id="tableName"
                                                   class="form-control" name="tableName"
                                                   datatype="*">
                                            <div class="help-block"></div>
                                        </div>
                                    </div>

                                    <div class="form-group field-article-author required">
                                        <div class='col-sm-2 text-right'>
                                            <label class="control-label Validform_label"
                                                   for="namespace">命名空间</label>
                                            </div>

                                            <div class='col-sm-10'>
                                                <input type="text" id="namespace" class="form-control" name="namespace" datatype="*" value="app\common\model">
                                            <div class="help-block">根据项目实际而定，默认生成在app\common\model下,注:命名空间需要与目录对应</div>
                                            </div>
                                    </div>

                                    <div class="form-group field-article-sort required">
                                        <div class='col-sm-2 text-right'>
                                            <label class="control-label Validform_label"
                                                   for="extendClass">继承基类</label></div>
                                        <div class='col-sm-10'>
                                            <input type="text" id="extendClass" class="form-control"name="extendClass" datatype="*" value="app\common\model\BaseModel">
                                            <div class="help-block">根据项目实际而定，默认继承app\common\model\BaseModel</div>
                                        </div>
                                    </div>

                                    <input type="hidden" id="is_continue" name="is_continue" value="0">
                                </div>
                                <div class="box-footer text-center">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>


{include file="index/footer-script" /}

<script>
    var validate = $("#pt_form").Validform({
        tiptype: function(msg,o,cssctl){
            if(o.type == 3){
                toastr.error(msg);
                return false;
            }
        },
        datatype:{
        },
        tipSweep:true, //是否失去焦点就验证
        postonce:true, //表单只提交一次
        ajaxPost:true, //异步提交表单
        beforeSubmit:function(curform){
            layer.load(2);
        },
        callback:function(data){
            layer.closeAll();
            if(data.code == 302){
                layer.confirm('模型文件已存在是否覆盖？',function(){
                    $('#is_continue').val(1);
                    $('#pt_form').submit();
                    return false;
                });
                return false;
            }
            if(data.code==300){
                toastr.error(data.msg);
                return false;
            }else{
                toastr.success(data.msg);
                setTimeout(function(){
                    window.location.reload();
                },toastr.options.timeOut);
                //window.location.reload();
                return false;
            }
        }
    });
</script>
</body>
</html>

